﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JiraGenCommon
{
    public sealed class GlobalVariables
    {
        static GlobalVariables _instance = null;
        static readonly object Padlock = new object();

        public static GlobalVariables Current
        {
            get
            {
                lock (Padlock)
                {
                    return _instance ?? (_instance = new GlobalVariables());
                }
            }
        }

        private string _jiraSoapServiceUrl;
        public string JiraSoapServiceUrl
        {
            get { return _jiraSoapServiceUrl; }
            set { _jiraSoapServiceUrl = value; }
        }
        public string JiraDefaultUser { get; set; }

        public string JiraServerUrl
        {
            get
            {
                if (string.IsNullOrEmpty(_jiraSoapServiceUrl)) return string.Empty;

                var jiraUri = new Uri(_jiraSoapServiceUrl);

                return string.Format("{0}://{1}:{2}", jiraUri.Scheme, jiraUri.Host, jiraUri.Port);
            }
        }
    }
}
